home *** CD-ROM | disk | FTP | other *** search
- /* File: HideCalls.h
-
- Description:
- This sample illustrates how the SetHideOnSwitch and GetHideOnSwitch
- routines can be used to hide an application. These routines were first
- documented in Technote TN1102, "Mac OS 8". On the world wide
- web, documentation for these routines can be found at the address:
-
- http://developer.apple.com/technotes/tn/tn1102.html#processmgr
-
- This file contains constant and declarations necessary for using these
- routines along with definitions for routines defined in the file HideCalls.c.
-
- Copyright:
- Copyright © 1999 by Apple Computer, Inc.
- All rights reserved.
-
- Disclaimer:
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
-
- Change History (most recent first):
- 12/6/1999 created
- */
-
- #ifndef __HIDECALLS__
- #define __HIDECALLS__
-
- #include <MacTypes.h>
- #include <ConditionalMacros.h>
- #include <Events.h>
- #include <Processes.h>
-
-
- /* gestaltHideLayerOnSwitchSupport is a bit defined in the
- response returned by the gestaltOSAttr Gestalt selector.
- If this bit is set, then you can use the routines defined
- in this file. */
- enum {
- gestaltHideLayerOnSwitchSupport = 16
- };
-
-
- /* HideCallsExist returns true if the gestaltHideLayerOnSwitchSupport
- bit is set in the response returned by the gestaltOSAttr Gestalt
- selector. If this routine returns true, then it is safe to call
- SetHideOnSwitch and GetHideOnSwitch. */
- Boolean HideCallsExist(void);
-
-
- /* SetHideOnSwitch sets the 'hide on switch' global variable to
- the value stored in setValue. If the 'hide on switch' global
- variable is true, then processes will be hidden every time
- they are switched out by the process manager. */
- extern pascal void SetHideOnSwitch(Boolean setValue)
- THREEWORDINLINE(0x3F3C, 0x006B, 0xA88F);
-
- /* GetHideOnSwitch queries and returns the state of the
- 'hide on switch' global variable. */
- extern pascal Boolean GetHideOnSwitch(void)
- THREEWORDINLINE(0x3F3C, 0x006C, 0xA88F);
-
-
-
- /* HideMe is a routine you can use to hide your application on
- demand. Its functionality relies on the presence of the
- SetHideOnSwitch routine and the process manager.
-
- HideMe works by turning on the 'hide on switch' variable to
- true, switching out its own process, and then turning off
- the 'hide on switch' flag after its process has been switched
- out.
-
- The following describes HideMe and it's support routines. */
-
-
- /* EventIdleProc is a routine your application defines and passes
- to the HideMe routine. The Process Manager switches processes
- in and out of the foreground during calls to WaitNextEvent. Because
- of this, HideMe calls WaitNextEvent while it is waiting for a process
- to be switched in or out of the forground. Any events returned
- during those times are passed back to your application through the
- EventIdleProc you provide as a parameter to the HideMe routine.
-
- If your EventIdleProc returns any result code other than noErr,
- HideMe will abort and return that error code. */
- typedef OSStatus (*EventIdleProc)(EventRecord *ev);
-
- /* SelectNextFrontProcess is a callback your application provides to the
- HideMe routine. After setting the 'hide on switch' flag, HideMe needs
- to switch another process into the forground in order to switch itself
- out (and thereby make itself invisible). This routine provides an
- opportunity for your application to select which process will be switched
- into the forground. */
- typedef OSStatus (*SelectNextFrontProcess)(ProcessSerialNumber *myPSN, ProcessSerialNumber *targetPSN);
-
- /* HideMe hides the current process making it invisible. Calling this routine
- is the same as calling the 'Hide xxxxxx' command from the application
- menu in the top right corner of the screen. HideIdleProc is a routine
- of type EventIdleProc that is called by HideMe while it is waiting for the
- ProcessManager to switch processes in and out of the forground, and
- GetNextP is a routine of type SelectNextFrontProcess that is used by
- HideMe to select the process that is to be moved into the forground
- when it is hidden. */
- OSStatus HideMe(EventIdleProc HideIdleProc, SelectNextFrontProcess GetNextP);
-
- #endif
-